<template>
  <van-cell title="当前用户" :value="user?.username" />
  <van-cell title="个人信息" is-link @click="router.push('/User/userInfo')" />
  <van-cell title="我创建的" is-link @click="router.push('/User/Team/create')" />
  <van-cell title="我加入的" is-link @click="router.push('/User/Team/join')" />
</template>

<script setup lang="ts">
import { useUserStore } from '@/stores/user'
import { ref, onMounted } from 'vue'
import { useRouter } from 'vue-router'

defineExpose({
  name: '我的',
})
const user = ref()
const router = useRouter()
const userStore = useUserStore()
onMounted(() => {
  getUser()
})

const getUser = () => {
  if (Object.keys(userStore.getCurrentUser()).length !== 0) {
    user.value = userStore.getCurrentUser()
  } else {
    // router.replace({
    //   path: '/login',
    // })
  }
}
</script>
